package com.example.demo.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.Dto.LoginDto;
import com.example.demo.Dto.LogoffDto;
import com.example.demo.Dto.RegisterDto;
import com.example.demo.Dto.UserUpdateDto;
import com.example.demo.po.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    // 注册
    @Insert("insert into user(user_id,email,password) values(#{id}, #{registerDto.email},#{registerDto.password})")
 int register(@Param("registerDto") RegisterDto registerDto, @Param("id") long  id);
    @Select("select user_id from user where user_id=#{userId}")
    Long refresh(@Param("userId") Object userId);
@Select("select * from user where user_id= #{user.userId}")
    User getUser(@Param("user") User user);
@Update("update user set status=#{logoffDto.status},disable_reason=#{logoffDto.reason} where user_id=#{userId}")
    int updatestatus(@Param("logoffDto") LogoffDto logoffDto,@Param("userId") Long userId);
@Update("update user set user_name=#{userUpdateDto.username},phone=#{userUpdateDto.phone},city=#{userUpdateDto.city},province=#{userUpdateDto.province},country=#{userUpdateDto.country},zip_code=#{userUpdateDto.zipCode},user_currency=#{userUpdateDto.currency} where user_id=#{userId}")
    int updatestatus1(@Param("userUpdateDto") UserUpdateDto userUpdateDto, @Param("userId") Long userId);
}
